package com.acme.mock;

import java.io.Serializable;

public class SavingAccount extends AbstractAccount implements Serializable{

	public SavingAccount(){
		super();
	}
	
	public SavingAccount(double balance) throws IllegalArgumentException{
		super();
		if(balance < 0)
			throw new IllegalArgumentException("balance < 0");
		else
			setBalance(balance);
	}
	
	@Override
	public double maximumAmountToWithdraw() {
		return getBalance();
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if(this == obj) return true;
		if(this.hashCode() != obj.hashCode()) return false;
		final SavingAccount other = (SavingAccount) obj;
		if(this.getBalance() != other.getBalance()) return false;
		return true;
	}
	
}
